<template>
  <div>{{ parkId }}</div>
  <el-table :data="data" border max-height="460">
    <el-table-column type="index" label="序号" width="80" align="center" />
    <el-table-column property="name" label="企业名称" align="center" />
    <el-table-column property="address" label="统一信用代码" align="center" />
    <el-table-column property="date" label="生效时间" width="160" align="center" />
    <el-table-column property="date" label="适用企业" width="160" align="center">
      <template #default="{ row }">
        <el-link type="primary" @click="handleViewCompany(row)">{{ row.date }}</el-link>
      </template>
    </el-table-column>
    <el-table-column property="action" label="操作" width="160" align="center">
      <template #default="{ row }">
        <el-button text size="small" type="primary" @click="handleEdit(row)">编辑</el-button>

        <el-popconfirm
          title="确定要删除选中数据吗？"
          @confirm="handleRemove(row)"
          :width="240"
          placement="top"
        >
          <template #reference>
            <el-button text size="small" type="danger">删除</el-button>
          </template>
        </el-popconfirm>
      </template>
    </el-table-column>
  </el-table>

  <evaluation-company-modal v-model="evaluationCompanyModalVisible" />
  <evaluation-system-edit-modal v-model="evaluationSystemEditModalVisible" />
</template>

<script setup lang="ts">
import { EvaluationSystemItem } from '../../types'
import EvaluationCompanyModal from '../EvaluationCompanyModal/index.vue'
import EvaluationSystemEditModal from '../EvaluationSystemEditModal/index.vue'

defineOptions({
  name: 'EvaluationSystemList'
})

const evaluationCompanyModalVisible = ref(false)
const evaluationSystemEditModalVisible = ref(false)

defineProps({
  parkId: {
    type: String,
    required: false
  }
})

const currentEntity = ref<EvaluationSystemItem | null>(null)

const handleViewCompany = (record: EvaluationSystemItem) => {
  currentEntity.value = record
  evaluationCompanyModalVisible.value = true
}

const handleEdit = (record: EvaluationSystemItem) => {
  currentEntity.value = record
  evaluationSystemEditModalVisible.value = true
}

const handleRemove = (record: EvaluationSystemItem) => {}

const data = reactive<EvaluationSystemItem[]>([
  {
    date: '2016-05-02',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District'
  },
  {
    date: '2016-05-04',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District'
  },
  {
    date: '2016-05-01',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District'
  },
  {
    date: '2016-05-03',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District'
  },
  {
    date: '2016-05-03',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District'
  },
  {
    date: '2016-05-03',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District'
  },
  {
    date: '2016-05-03',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District'
  },
  {
    date: '2016-05-03',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District'
  },
  {
    date: '2016-05-03',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District'
  },
  {
    date: '2016-05-03',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District'
  }
])
</script>
